package org.ushio.nchu_22201402.controller;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.ushio.common_module.entity.Admin;
import org.ushio.nchu_22201402.service.Admin_LoginService;

import java.util.List;

@RestController
@CrossOrigin
public class Admin_LoginController {

    @Autowired
    private Admin_LoginService admin_loginService;

    @GetMapping("/AllAdmin")
    public List<Admin> AllAdmin() {
        return admin_loginService.AllAdmin();
    }


    @PostMapping("/login")
    public String AdminLogin(@RequestBody Admin admin) {
        System.out.println(admin);
        //先验证都不为空，再去比对数据库
        boolean isLoggin = admin_loginService.Login(admin.getAdmin_id(), admin.getPassword());
        if (isLoggin) {

            return "success";
        } else {

            return "失败";
        }
    }
}